package java8.stream;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;

/**
 * @author Cheng Jun
 * @version 1.0
 * Description:
 * @date 2019/8/6 16:22
 */
public class WapperStream {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        list.add("1");
        System.out.println(list.stream().mapToDouble(Double::valueOf).sum());
        IntStream.of(new int[]{1, 2, 3}).forEach(a -> System.out.println(a));
        IntStream.range(1, 3).forEach(System.out::println);
        IntStream.rangeClosed(1, 3).forEach(System.out::println);

        IntStream intStream = IntStream.rangeClosed(1, 100);
        System.out.println(intStream.sum());
        // 流可以且只可以被使用一次
        // Exception in thread "main" java.lang.IllegalStateException: stream has already been operated upon or closed
        // System.out.println(intStream.max());
    }


}
